package com.example.myandroid;

import org.mobilesynergies.epic.client.EpicCommandInfo;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

public class MyAndroidAppActivity extends Activity
{

   protected final String CLASS_TAG = MyAndroidAppActivity.this.getClass().getName();

   /** Called when the activity is first created. */
   @Override
   public void onCreate( Bundle savedInstanceState )
   {
      super.onCreate( savedInstanceState );
      setContentView( R.layout.main );
      String strServiceName = MyService.class.getName();
      EpicCommandInfo epicCommandInfo = new EpicCommandInfo();
      bindService( new Intent( strServiceName ), mServiceConnection, Context.BIND_AUTO_CREATE );

   }

   private ServiceConnection mServiceConnection = new ServiceConnection()
                                                {

                                                   public void onServiceConnected( ComponentName className,
                                                                                   IBinder service )
                                                   {
                                                      IMyInterface mService = (IMyInterface) IMyInterface.Stub.asInterface( service );
                                                      try
                                                      {
                                                         Log.d( CLASS_TAG, "Service connected:" + mService.foo() );
                                                      }
                                                      catch( RemoteException e )
                                                      {
                                                         // TODO Auto-generated catch block
                                                         e.printStackTrace();
                                                      }
                                                   }

                                                   public void onServiceDisconnected( ComponentName className )
                                                   {
                                                   }
                                                };

}
